#![feature(allocator_api)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(prelude_import)]
#![feature(proc_macro_hygiene)]
#![feature(slice_ptr_get)]
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

pub mod tasks;
pub mod thr;

#[prelude_import]
#[allow(unused_imports)]
use drone_core::prelude::*;

use drone_core::heap;
use drone_{{bindings_name}}_map::{{bindings_name}}_reg_tokens;
{{~#if (eq dso_name "nrf91")}}

drone_nrf91_dso::set_log! {
    periph: Uarte0S,
    pin_number: 29,
    buf_size: 64,
}
{{~/if}}{{#if (or (eq log_ident "swoprobe") (eq log_ident "swoserial"))}}

drone_{{platform_name}}::swo::set_log!();
{{~/if}}

{{bindings_name}}_reg_tokens! {
    /// A set of tokens for all memory-mapped registers.
    index => pub Regs;

    exclude => {

{{~#if dso_regs}}
{{dso_regs}}
{{/if ~}}

{{~ #if (or (eq log_ident "swoprobe") (eq log_ident "swoserial"))}}
        dwt_cyccnt,
        itm_tpr, itm_tcr, itm_lar,
        tpiu_acpr, tpiu_sppr, tpiu_ffcr,
{{~/if}}

        scb_ccr,
        mpu_type, mpu_ctrl, mpu_rnr, mpu_rbar, mpu_rasr,
    }
}

heap! {
    // Heap configuration key in `Drone.toml`.
    config => main;
    /// The main heap allocator generated from the `Drone.toml`.
    metadata => pub Heap;
    // Use this heap as the global allocator.
    global => true;
    // Uncomment the following line to enable heap tracing feature:
    // trace_port => 31;
}

/// The global allocator.
#[cfg_attr(not(feature = "std"), global_allocator)]
pub static HEAP: Heap = Heap::new();
